import Vue from 'vue'
import App from './App'
import commonApi from "./api/common.js"
import uView from 'uview-ui';
import store from '@/store';
Vue.use(uView);
import $ from '@/common/fun.js';
// 引入uView提供的对vuex的简写法文件
let vuexStore = require('@/store/$u.mixin.js');
Vue.mixin(vuexStore);
// 引入uView对小程序分享的mixin封装
// let mpShare = require('uview-ui/libs/mixin/mpShare.js');
// Vue.mixin(mpShare)
Vue.prototype.$ = $
Vue.prototype.$commonApi = commonApi; // 公共接口

// Vue.prototype.mapkey = '5BLBZ-OYXYW-CDHR5-R7H6N-GJESQ-QJFG4'
Vue.config.productionTip = false
Vue.prototype.$is_menuButtonInfo = false
// Vue.prototype.imgUrl = "https://wpscxcx.oss-cn-chengdu.aliyuncs.com/Durian/"


let navheight = uni.getSystemInfoSync().platform == 'ios' ? 44 : uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = {};
// 如果是小程序，获取右上角胶囊的尺寸信息，避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API，尚未兼容)
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
menuButtonInfo = uni.getMenuButtonBoundingClientRect();
Vue.prototype.$is_menuButtonInfo = true
// #endif
Vue.prototype.$navbarHeight = menuButtonInfo != '' && menuButtonInfo.top ? (menuButtonInfo.top + navheight) : navheight
App.mpType = 'app'

//页面跳转方法
function openPage(isToken, t, u, d) {
	if (!u) {
		return uni.showToast({
			title: '暂未开放~',
			icon: 'none'
		});
	}
	let _this = this
	if (isToken == 'true') {
		let lifeData = uni.getStorageSync('lifeData')
		// 开发期间默认正常跳转，上线去掉
		if (lifeData.token) {
			_this.$u.route({
				type: t,
				url: u,
				params: d,
			});
		} else {
			_this.$.toast('请登录！')
			setTimeout(() => {
				uni.navigateTo({
					url: '/pages/login/index',
				});
			}, 200)
		}
	} else {
		_this.$u.route({
			type: t,
			url: u,
			params: d
		});
	}
}

Vue.prototype.openPage = openPage
const app = new Vue({
	store,
	...App
})
app.$mount()